***********************************
** The Effects of House Prices and Home Equity Extraction on Career Outcomes
** by Jacelly Cespedes, Zack Liu, and Carlos Parra
***********************************

// Directories
global data C:\Users\Dropbox\Data
global output C:\Users\Dropbox\Data\Results


***********************************
** figures
***********************************

*** Figure 1: Industry statistics

cd "$data"
use "industry_statistics_2", clear
cd "$output"

// Panel A: Box office
twoway (line box_office_usa year, ytitle("Billions USD") yscale(range(0 12)) ylabel(0(4)12)) ///
       || (line *ave*price_tick year, yaxis(2) ytitle("Average ticket price", axis(2)) yscale(range(0 12) axis(2)) ylabel(0(4)12, axis(2))), ///
       xtitle("Year") ///
       legend(order(1 "Box-office returns" 2 "Average price per ticket") rows(1))

// Panel B: Big and small budget films, and HP films  
graph bar (asis) big_film_prod small_film_prod, over(year) stack ///
    ytitle("Films") ylabel(0(200)800) ///
    legend(label(1 "Big-budget films") label(2 "Small-budget films")) ///
    title("Big and Small Budget Films")
	
twoway line hp_film_perc year, ///
    ytitle("Percent") ylabel(0(3)12) ///
    xtitle("Year") ///
    title("High-Profile Films") ///
    legend(label(1 "HP films"))



*** Figure 2: Distribution of house price changes

use  "Zip_EOY_Zhvi_All.dta", clear

gen zip = propertyzip
mmerge zip using "census/zip_fips_v2"

*fipscounty is a string variable
gen in_county = 1 if fipscounty == "06037"
replace in_county = 1 if fipscounty == "36061"
replace in_county = 1 if fipscounty == "06059"
replace in_county = 1 if fipscounty == "36047"

keep if in_county == 1

*generate HP Change
keep if year == 2008 | year == 2012
sort zip year, stable
gen HP_Change = zhvi/zhvi[_n-1] - 1 if zip == zip[_n-1]
keep if year == 2012

cd "$output"
hist HP_Change if fipscounty == "06037", title("LA County") percent bin(10) xlabel(-0.4(0.1)0.2) ylabel(0(10)30, nogrid) xtitle("House Price Change") ytitle("Percent")  name(la)
hist HP_Change if fipscounty == "36061", title("New York County") percent bin(10) xlabel(-0.4(0.1)0.2) ylabel(0(10)30, nogrid) xtitle("House Price Change") ytitle("Percent") name(ny)
hist HP_Change if fipscounty == "06059", title("Orange County")  percent bin(10) xlabel(-0.4(0.1)0.2) ylabel(0(10)30, nogrid) xtitle("House Price Change") ytitle("Percent") name(oc)
hist HP_Change if fipscounty == "36047", title("Kings (Brooklyn) County")   percent bin(10) xlabel(-0.4(0.1)0.2) ylabel(0(10)30, nogrid) xtitle("House Price Change") ytitle("Percent") name(br)

gr combine la ny oc br, xcommon ycommon


*** Figure 3: Crew size, film budget, local box office, awards, and movie rating
cd "$data"
use "data_main_graphs_v1", clear
cd "$output"

gen crew_size_bin=150 *floor(crew_size/150 )

// Panel A: Crew size and budget
egen budget_n_1 = mean(budget_n), by(crew_size_bin) 
twoway (scatter budget_n_1 crew_size_bin, msymbol(circle_hollow) mcolor(navy)), ///
    ytitle("Budget (millions USD)") xtitle("Crew size") ///
    xlabel(0(1000)4000) ylabel(0(50)250) ///
    name(budget, replace)

// Panel B: Crew size and local box office
egen box_office_usa_1 = mean(box_office_usa), by(crew_size_bin) 
twoway (scatter box_office_usa_1 crew_size_bin, msymbol(circle_hollow) mcolor(navy)), ///
    ytitle("Local box office (millions USD)") xtitle("Crew size") ///
    xlabel(0(1000)4000) ylabel(0(200)600) ///
    name(boxoffice, replace)

// Panel C: Crew size and awards
egen won_nom_award_1 = mean(won_nom_award_pre), by(crew_size_bin)
twoway (scatter won_nom_award_1 crew_size_bin, msymbol(circle_hollow) mcolor(navy)), ///
    ytitle("Awards") xtitle("Crew size") ///
    xlabel(0(1000)4000) ylabel(0.2(0.2)1) ///
    name(awards, replace)

// Panel D: Crew size and movie rating
egen movie_rating_1 = mean(movie_rating), by(crew_size_bin)
twoway (scatter movie_rating_1 crew_size_bin, msymbol(circle_hollow) mcolor(navy)), ///
    ytitle("Movie rating") xtitle("Crew size") ///
    xlabel(0(1000)4000) ylabel(5.5(0.5)7.5) ///
    name(rating, replace)

// Combine all graphs
graph combine budget boxoffice awards rating, rows(2) cols(2)



*** Figure 4: Differences in film characteristics
cd "$data"
use "data_main_graphs_v1", clear
cd "$output"

gen type_project = ""
replace type_project = "Small" if crew_size_q1 == 1
replace type_project = "Large" if crew_size_q4 == 1

gen type_project2 = ""
replace type_project2 = "HP films" if high_profile_project == 1
replace type_project2 = "Non-HP films" if high_profile_project == 0

// Panel A: Small- and big-budget films
graph bar (mean) filming_duration, over(type_project) ///
    ytitle("Days") ylabel(0(20)100) bargap(30) ///
    legend(off) name(duration_a, replace)
    
graph bar (mean) crew_size, over(type_project) ///
    ytitle("People") ylabel(0(100)500) bargap(30) ///
    legend(off) name(crew_a, replace)
    
graph bar (mean) box_office_usa, over(type_project) ///
    ytitle("Millions USD") ylabel(0(20)60) bargap(30) ///
    legend(off) name(boxoffice_a, replace)
    
graph bar (mean) budget_n, over(type_project) ///
    ytitle("Millions USD") ylabel(0(10)50) bargap(30) ///
    legend(off) name(budget_a, replace)

// Panel B: Characteristics of high-profile films
graph bar (mean) filming_duration, over(type_project2) ///
    ytitle("Days") ylabel(0(50)150) bargap(30) ///
    legend(off) name(duration_b, replace)
    
graph bar (mean) crew_size, over(type_project2) ///
    ytitle("People") ylabel(0(100)400) bargap(30) ///
    legend(off) name(crew_b, replace)
    
graph bar (mean) box_office_usa, over(type_project2) ///
    ytitle("Millions USD") ylabel(0(20)60) bargap(30) ///
    legend(off) name(boxoffice_b, replace)
    
graph bar (mean) budget_n, over(type_project2) ///
    ytitle("Millions USD") ylabel(0(10)50) bargap(30) ///
    legend(off) name(budget_b, replace)

// Combine all graphs
graph combine duration_a crew_a boxoffice_a budget_a ///
             duration_b crew_b boxoffice_b budget_b, ///
    rows(2) cols(4)


*** Figure 5: Housing price shocks and film choices: Intensity of treatment
cd "$data"
use "data_for_reg_v3", clear
cd "$output"

// Common graph options
local graph_opts "vertical keep(HP_change_qi1 HP_change_qi2 HP_change_qi3 HP_change_qi4) yline(0) levels(95) coeflabels(HP_change_qi1 = "20%" HP_change_qi2 = "40%" HP_change_qi3 = "60%" HP_change_qi4 = "80%") xtitle("") xlabel(, labsize(small))"

// Panel A: Main outcomes
reghdfe hp_movie_dum HP_change_qi1 HP_change_qi2 HP_change_qi3 HP_change_qi4 female age_2007 num_awards_pre movie_0306 total_hp_movie_pre if movie_0306 > 0 & renter == 0, absorb(fipscounty occ1 occ2) vce(cluster zip) 
coefplot, `graph_opts' ytitle("HP film dummy") ylabel(-0.15(0.05)0.05) name(g1, replace)

reghdfe total_hp_movie HP_change_qi1 HP_change_qi2 HP_change_qi3 HP_change_qi4 female age_2007 num_awards_pre movie_0306 total_hp_movie_pre if movie_0306 > 0 & renter == 0, absorb(fipscounty occ1 occ2) vce(cluster zip)
coefplot, `graph_opts' ytitle("Number HP films") ylabel(-0.3(0.1)0.1) name(g2, replace)

reghdfe total_movie_bq4 HP_change_qi1 HP_change_qi2 HP_change_qi3 HP_change_qi4 female age_2007 num_awards_pre movie_0306 total_movie_bq4_pre if movie_0306 > 0 & renter == 0, absorb(fipscounty occ1 occ2) vce(cluster zip)
coefplot, `graph_opts' ytitle("Number large films") ylabel(-0.4(0.2)0.2) name(g3, replace)

reghdfe total_movie_sq1 HP_change_qi1 HP_change_qi2 HP_change_qi3 HP_change_qi4 female age_2007 num_awards_pre movie_0306 total_movie_sq1_pre if movie_0306 > 0 & renter == 0, absorb(fipscounty occ1 occ2) vce(cluster zip)
coefplot, `graph_opts' ytitle("Number small films") ylabel(-0.1(0.1)0.3) name(g4, replace)

// Panel B: Other outcomes
reghdfe won_nom_award HP_change_qi1 HP_change_qi2 HP_change_qi3 HP_change_qi4 female age_2007 num_awards_pre movie_0306 total_hp_movie_pre if movie_0306 > 0 & renter == 0, absorb(fipscounty occ1 occ2) vce(cluster zip)
coefplot, `graph_opts' ytitle("Award") ylabel(-0.3(0.1)0.1) name(g5, replace)

reghdfe movie_rating HP_change_qi1 HP_change_qi2 HP_change_qi3 HP_change_qi4 female age_2007 num_awards_pre movie_0306 total_hp_movie_pre movie_rating_pre if movie_0306 > 0 & renter == 0, absorb(fipscounty occ1 occ2) vce(cluster zip)
coefplot, `graph_opts' ytitle("Movie rating") ylabel(-0.8(0.2)0) name(g6, replace)

reghdfe leading_role_mean HP_change_qi1 HP_change_qi2 HP_change_qi3 HP_change_qi4 female age_2007 num_awards_pre movie_0306 total_hp_movie_pre leading_role_mean_pre if movie_0306 > 0 & renter == 0 & occupation=="actors", absorb(fipscounty occ1 occ2) vce(cluster zip)
coefplot, `graph_opts' ytitle("Leading role") ylabel(-0.15(0.05)0.05) name(g7, replace)

graph combine g1 g2 g3 g4, rows(1) cols(4) ysize(5) xsize(16) name(panel_a, replace)
graph combine g5 g6 g7, rows(1) cols(3) ysize(5) xsize(16) name(panel_b, replace)




*** Figure 6: Randomization inference
clear all
estimates clear
set matsize 10000

cd "$data"
use "data_for_reg_v3", clear
count  
di c(k)  
cd "$output"

keep if renter == 0
drop if HP_change ==.
local var "hp_movie_dum HP_change female age_2007 num_awards_pre movie_0306 total_hp_movie_pre  occ1 occ2"
foreach i of local var {
drop if `i'==.
}

matrix results = J(10000, 7, .) // Create matrix to store results

// baseline results (Table 2 & 3)
reghdfe hp_movie_dum HP_change female age_2007 num_awards_pre movie_0306 total_hp_movie_pre     if movie_0306 > 0 & renter == 0 , absorb(fipscounty occ1 occ2) vce(cluster zip) 
matrix results[1,1] = _b[HP_change]

reghdfe total_hp_movie HP_change female age_2007 num_awards_pre movie_0306 total_hp_movie_pre   if movie_0306 > 0 & renter == 0 , absorb(fipscounty occ1 occ2)  vce(cluster zip)
matrix results[1,2] = _b[HP_change]

reghdfe total_movie_bq4 HP_change female age_2007 num_awards_pre movie_0306  total_movie_bq4_pre     if movie_0306 > 0 & renter == 0 , absorb(fipscounty occ1 occ2)  vce(cluster zip)
matrix results[1,3] = _b[HP_change]

reghdfe total_movie_sq1 HP_change female age_2007 num_awards_pre movie_0306  total_movie_sq1_pre    if movie_0306 > 0 & renter == 0 , absorb(fipscounty occ1 occ2)  vce(cluster zip)
matrix results[1,4] = _b[HP_change]

reghdfe won_nom_award HP_change female age_2007 num_awards_pre movie_0306 total_hp_movie_pre  if movie_0306 > 0 & renter == 0  , absorb(fipscounty occ1 occ2 ) vce(cluster zip)
matrix results[1,5] = _b[HP_change]

reghdfe movie_rating HP_change female age_2007 num_awards_pre movie_0306 total_hp_movie_pre movie_rating_pre   if movie_0306 > 0 & renter == 0  , absorb(fipscounty occ1 occ2 ) vce(cluster zip)
matrix results[1,6] = _b[HP_change]

reghdfe leading_role_mean HP_change female age_2007 num_awards_pre movie_0306 total_hp_movie_pre leading_role_mean_pre  if movie_0306 > 0 & renter == 0  & occupation=="actors" , absorb(fipscounty occ1 occ2) vce(cluster zip)
matrix results[1,7] = _b[HP_change]

// permutation
sort nconst, stable
egen id=group(nconst)
summ id

forvalues b = 2/10000 {

preserve

rename id id_orig
drop HP_change

gen id_raw = uniform()
sort id_orig, stable
by id_orig: replace id_raw = id_raw[1]
egen id = group(id_raw)

sort id, stable
merge id using "$data\id_HP_change"
tab _merge
drop if _merge == 2
drop _merge

reghdfe hp_movie_dum HP_change female age_2007 num_awards_pre movie_0306 total_hp_movie_pre     if movie_0306 > 0 & renter == 0 , absorb(fipscounty occ1 occ2) vce(cluster zip) 
matrix results[`b',1] = _b[HP_change]

reghdfe total_hp_movie HP_change female age_2007 num_awards_pre movie_0306 total_hp_movie_pre   if movie_0306 > 0 & renter == 0 , absorb(fipscounty occ1 occ2)  vce(cluster zip)
matrix results[`b',2] = _b[HP_change]

reghdfe total_movie_bq4 HP_change female age_2007 num_awards_pre movie_0306  total_movie_bq4_pre     if movie_0306 > 0 & renter == 0 , absorb(fipscounty occ1 occ2)  vce(cluster zip)
matrix results[`b',3] = _b[HP_change]

reghdfe total_movie_sq1 HP_change female age_2007 num_awards_pre movie_0306  total_movie_sq1_pre    if movie_0306 > 0 & renter == 0 , absorb(fipscounty occ1 occ2)  vce(cluster zip)
matrix results[`b',4] = _b[HP_change]

reghdfe won_nom_award HP_change female age_2007 num_awards_pre movie_0306 total_hp_movie_pre  if movie_0306 > 0 & renter == 0  , absorb(fipscounty occ1 occ2 ) vce(cluster zip)
matrix results[`b',5] = _b[HP_change]

reghdfe movie_rating HP_change female age_2007 num_awards_pre movie_0306 total_hp_movie_pre movie_rating_pre   if movie_0306 > 0 & renter == 0  , absorb(fipscounty occ1 occ2 ) vce(cluster zip)
matrix results[`b',6] = _b[HP_change]

reghdfe leading_role_mean HP_change female age_2007 num_awards_pre movie_0306 total_hp_movie_pre leading_role_mean_pre  if movie_0306 > 0 & renter == 0  & occupation=="actors" , absorb(fipscounty occ1 occ2) vce(cluster zip)
matrix results[`b',7] = _b[HP_change]

drop _all
svmat results
list if _n == 1
summ results* if _n > 1, det
cd "$data"
save randomization_inference_results_new2.dta, replace

restore
}

preserve
drop _all
svmat results
list if _n == 1
summ results* if _n > 1, det
save randomization_inference_results_new2.dta, replace
restore

// permutation figures
clear all
estimates clear
set matsize 10000
graph set window fontface "Garamond"

use randomization_inference_results_new2, replace
cd "$output"

forvalues i = 1/7 {
 preserve
 global result = results`i'[1]
 drop if _n == 1
 count
 local N = r(N)
 if ($result < 0) {
  count if $result > results`i'
  local c = r(N)
  local p = 2*`c'/`N'
 }
 else {
  count if $result < results`i'
  local c = r(N)
  local p = 2*`c'/`N'
 } 
 di "(two-sided) p-val (`i') = `p'"
 restore
}

local i = 1
 preserve
 global result = results`i'[1]
 drop if _n == 1
 keep results`i' 
 gen resultx = $result if _n == 1
 summ resultx results`i'
 gen resulty = 3 if _n == 1

 local y2 = 1 * 2.8
 local x2 = $result * 1
 local y1 = `y2' * 1.4
 local x1 = `x2' * .9

 tw ///
  (kdensity results`i', lcolor(blue) ) (bar resulty resultx, color(gray) barwidth(0.01) ) ///
  (pcarrowi `y1' `x1' `y2' `x2' (9) , msize(vsmall) mcolor(gray) mlabsize(medium) ), /// 
  legend(off) xtitle("HP film dummy") ytitle("density") xscale(r(-0.5 0.5)) ///
  scheme(s2mono) ylabel(, nogrid angle(horizontal) ) yscale(nofextend) xscale(nofextend) graphregion(fcolor(white))

 graph save  permutation`i'.gph, replace
 restore
 
local i = 2
 preserve
 global result = results`i'[1]
 drop if _n == 1
 keep results`i' 
 gen resultx = $result if _n == 1
 gen resulty = 3 if _n == 1
 summ resultx results`i'

 local y2 = 1 * 2.9
 local x2 = $result * 1
 local y1 = `y2' * 1.4
 local x1 = `x2' * .9
 
 tw ///
  (kdensity results`i', lcolor(blue) ) (bar resulty resultx, barwidth(0.01) color(gray) ) ///
  (pcarrowi `y1' `x1' `y2' `x2' (9) , msize(vsmall) mcolor(gray) mlabsize(medium) ), /// 
  legend(off) xtitle("No. HP films") ytitle("density") xscale(r(-0.5 0.5))   ///
  scheme(s2mono) ylabel(, nogrid angle(horizontal) ) yscale(nofextend) xscale(nofextend) graphregion(fcolor(white))

 graph save  permutation`i'.gph, replace
 restore
 
 local i = 3
 preserve
 global result = results`i'[1]
 drop if _n == 1
 keep results`i' 
 gen resultx = $result if _n == 1
 gen resulty = 3 if _n == 1
 summ resultx results`i'

 local y2 = 1 * 2.8
 local x2 = $result * 1
 local y1 = `y2' * 1.4
 local x1 = `x2' * 0.01

 tw ///
  (kdensity results`i', lcolor(blue) ) (bar resulty resultx, color(gray) barwidth(0.01) ) ///
  (pcarrowi `y1' `x1' `y2' `x2' (3) , msize(vsmall) mcolor(gray) mlabsize(medium) ), /// 
  legend(off) xtitle("No. large films") ytitle("density")  ///
   scheme(s2mono) ylabel(, nogrid angle(horizontal) ) yscale(nofextend) xscale(nofextend) graphregion(fcolor(white))

 graph save  permutation`i'.gph, replace
 restore

 local i = 4
 preserve
 global result = results`i'[1]
 drop if _n == 1
 keep results`i' 
 gen resultx = $result if _n == 1
 gen resulty = 4 if _n == 1
 summ resultx results`i'
 
 keep if results`i'<.8
 keep if results`i'>-.8
 
 local y2 = 4 * 1.10
 local x2 = $result * 0.99
 local y1 = `y2' * 1.11
 local x1 = `x2' * 1

 tw ///
  (kdensity results`i', lcolor(blue) ) (bar resulty resultx if  results`i'<.8 & results`i'>-.8, color(gray) barwidth(0.01) ) ///
  (pcarrowi `y1' `x1' `y2' `x2' (3) , msize(vsmall) mcolor(gray) mlabsize(medium) ), /// 
  legend(off) xtitle("No. small films") ytitle("density") ///
  scheme(s2mono) ylabel(, nogrid angle(horizontal) ) yscale(nofextend) xscale(nofextend) graphregion(fcolor(white))

 graph save  permutation`i'.gph, replace
 restore
 
 local i = 5
 preserve
 global result = results`i'[1]
 drop if _n == 1
 keep results`i' 
 gen resultx = $result if _n == 1
 gen resulty = 2 if _n == 1
 summ resultx results`i'

 local y2 = 2 * 1.02
 local x2 = $result * 0.98
 local y1 = `y2' * 1.13
 local x1 = `x2' * 0.95

 tw ///
  (kdensity results`i', lcolor(blue) ) (bar resulty resultx, color(gray) barwidth(0.01) ) ///
  (pcarrowi `y1' `x1' `y2' `x2' (9) , msize(vsmall) mcolor(gray) mlabsize(medium) ), /// 
  legend(off) xtitle("Award") ytitle("density") ///
  scheme(s2mono) ylabel(, nogrid angle(horizontal) ) yscale(nofextend) xscale(nofextend) graphregion(fcolor(white))

 graph save  permutation`i'.gph, replace
 restore
 
 local i = 6
 preserve
 global result = results`i'[1]
 drop if _n == 1
 keep results`i' 
 gen resultx = $result if _n == 1
 gen resulty = 1 if _n == 1
 summ resultx results`i'

 local y2 = 1 * 1.02
 local x2 = $result * 0.98
 local y1 = `y2' * 1.1
 local x1 = `x2' * 0.9

 tw ///
  (kdensity results`i', lcolor(blue) ) (bar resulty resultx, color(gray) barwidth(0.01) ) ///
  (pcarrowi `y1' `x1' `y2' `x2' (9) , msize(vsmall) mcolor(gray) mlabsize(medium) ), ///
  legend(off) xtitle("Movie rating") ytitle("density") ///
  scheme(s2mono) ylabel(, nogrid angle(horizontal) ) yscale(nofextend) xscale(nofextend) graphregion(fcolor(white))

 graph save  permutation`i'.gph, replace
 restore
 
 local i = 7
 preserve
 global result = results`i'[1]
 drop if _n == 1
 keep results`i' 
 gen resultx = $result if _n == 1
 gen resulty = 3 if _n == 1
 summ resultx results`i'

 local y2 = 1 * 3
 local x2 = $result * 0.98
 local y1 = `y2' * 1.1
 local x1 = `x2' * 0.9

 tw ///
  (kdensity results`i', lcolor(blue) ) (bar resulty resultx, color(gray) barwidth(0.01) ) ///
  (pcarrowi `y1' `x1' `y2' `x2' (9) , msize(vsmall) mcolor(gray) mlabsize(medium) ), ///
  legend(off) xtitle("Leading role") ytitle("density") ///
  scheme(s2mono) ylabel(, nogrid angle(horizontal) ) yscale(nofextend) xscale(nofextend) graphregion(fcolor(white))

 graph save  permutation`i'.gph, replace
 restore

graph combine  permutation1.gph permutation2.gph permutation3.gph permutation4.gph permutation5.gph permutation6.gph  permutation7.gph, ///
 title("Randomization Inference", size(small) ) col(2) ///
 iscale(0.42) ysize(7.0) xsize(6) ///
 scheme(s2mono) graphregion(fcolor(white)) 
graph save "randomization_inference_all", replace
 
 
*** Figure 7: Housing price shocks and film choices: Leads and lags intensity of treatment
cd "$data"
use "data_for_reg_v3", clear
cd "$output"


* hp_movie_dum
reghdfe hp_movie_dum HP_change_qi1 HP_change_qi2 HP_change_qi3 HP_change_qi4 female age_2007 num_awards_pre movie_0306 total_hp_movie_pre    if movie_0306 > 0 & renter == 0 , absorb(fipscounty occ1 occ2) vce(cluster zip) 
estimates store A

reghdfe hp_movie_dum_pre_o HP_change_qi1 HP_change_qi2 HP_change_qi3 HP_change_qi4 female age_2002 num_awards_0002 movie_0002 total_hp_movie_0002 if movie_0306 > 0 & renter == 0 , absorb(fipscounty occ1 occ2 ) vce(cluster zip) 
estimates store B

coefplot (A, color(maroon) mcolor(maroon) ciopts(color(maroon)) label(Before)) ///
         (B, color(navy) mcolor(navy) ciopts(color(navy)) label(After)), ///
    vertical keep(HP_change_qi1 HP_change_qi2 HP_change_qi3 HP_change_qi4 HP_change_qi4) ///
    yline(0) levels(95) name(g1, replace)

* total_hp_movie	
reghdfe total_hp_movie HP_change_qi1 HP_change_qi2 HP_change_qi3 HP_change_qi4 female age_2007 num_awards_pre movie_0306 total_hp_movie_pre  if movie_0306 > 0 & renter == 0 , absorb(fipscounty occ1 occ2 )  vce(cluster zip)
estimates store C

reghdfe total_hp_movie_pre_o HP_change_qi1 HP_change_qi2 HP_change_qi3 HP_change_qi4   female   age_2002 num_awards_0002 movie_0002 total_hp_movie_0002 if movie_0306 > 0 & renter == 0 , absorb(fipscounty occ1 occ2)  vce(cluster zip)
estimates store D

coefplot (C, color(maroon) mcolor(maroon) ciopts(color(maroon)) label(Before)) ///
         (D, color(navy) mcolor(navy) ciopts(color(navy)) label(After)), ///
    vertical keep(HP_change_qi1 HP_change_qi2 HP_change_qi3 HP_change_qi4 HP_change_qi4) ///
    yline(0) levels(95) name(g2, replace)

* total_movie_bq4	
reghdfe total_movie_bq4 HP_change_qi1 HP_change_qi2 HP_change_qi3 HP_change_qi4 female age_2007 num_awards_pre movie_0306  total_movie_bq4_pre     if movie_0306 > 0 & renter == 0 , absorb(fipscounty occ1 occ2)  vce(cluster zip)
estimates store E

reghdfe total_movie_bq4_pre_o HP_change_qi1 HP_change_qi2 HP_change_qi3 HP_change_qi4   female   age_2002 num_awards_0002 movie_0002 total_movie_bq4_0002  if movie_0306 > 0 & renter == 0 , absorb(fipscounty occ1 occ2)  vce(cluster zip)
estimates store F

coefplot (E, color(maroon) mcolor(maroon) ciopts(color(maroon)) label(Before)) ///
         (F, color(navy) mcolor(navy) ciopts(color(navy)) label(After)), ///
    vertical keep(HP_change_qi1 HP_change_qi2 HP_change_qi3 HP_change_qi4 HP_change_qi4) ///
    yline(0) levels(95)	name(g3, replace)

* total_movie_sq1	
reghdfe total_movie_sq1 HP_change_qi1 HP_change_qi2 HP_change_qi3 HP_change_qi4 female age_2007 num_awards_pre movie_0306  total_movie_sq1_pre    if movie_0306 > 0 & renter == 0 , absorb(fipscounty occ1 occ2)  vce(cluster zip)
estimates store G

reghdfe total_movie_sq1_pre_o HP_change_qi1 HP_change_qi2 HP_change_qi3 HP_change_qi4   female   age_2002 num_awards_0002 movie_0002 total_movie_sq1_0002  if movie_0306 > 0 & renter == 0 , absorb(fipscounty occ1 occ2)  vce(cluster zip)
estimates store H

coefplot (G, color(maroon) mcolor(maroon) ciopts(color(maroon)) label(Before)) ///
         (H, color(navy) mcolor(navy) ciopts(color(navy)) label(After)), ///
    vertical keep(HP_change_qi1 HP_change_qi2 HP_change_qi3 HP_change_qi4 HP_change_qi4) ///
    yline(0) levels(95)	name(g4, replace)
	
graph combine g1 g2 g3 g4, rows(2) cols(2) ysize(10) xsize(10) iscale(1)

	
*** Figure 8: Housing price shocks and film choices before 2007
cd "$data"
use "data_for_reg_0206", clear
cd "$output"

reghdfe hp_movie_dum_0206 HP_change_qi1_0206 HP_change_qi2_0206 HP_change_qi3_0206 HP_change_qi4_0206 female age_2002 num_awards_0002 movie_0002 total_hp_movie_0002    if movie_0306 > 0 & renter == 0 , absorb(fipscounty occ1 occ2) vce(cluster zip) 
coefplot, vertical keep(HP_change_qi1 HP_change_qi2 HP_change_qi3 HP_change_qi4) yline(0)  levels(95) name(g1, replace)

reghdfe total_hp_movie_0206 HP_change_qi1_0206 HP_change_qi2_0206 HP_change_qi3_0206 HP_change_qi4_0206 female age_2002 num_awards_0002 movie_0002 total_hp_movie_0002  if movie_0306 > 0 & renter == 0 , absorb(fipscounty occ1 occ2 )  vce(cluster zip)
coefplot, vertical keep(HP_change_qi1 HP_change_qi2 HP_change_qi3 HP_change_qi4) yline(0)   levels(95) name(g2, replace)

reghdfe total_movie_bq4_0206 HP_change_qi1_0206 HP_change_qi2_0206 HP_change_qi3_0206 HP_change_qi4_0206 female age_2002 num_awards_0002 movie_0002 total_movie_bq4_0002     if movie_0306 > 0 & renter == 0 , absorb(fipscounty occ1 occ2)  vce(cluster zip)
coefplot, vertical keep(HP_change_qi1 HP_change_qi2 HP_change_qi3 HP_change_qi4) yline(0)   levels(95) name(g3, replace)

reghdfe total_movie_sq1_0206 HP_change_qi1_0206 HP_change_qi2_0206 HP_change_qi3_0206 HP_change_qi4_0206 female age_2002 num_awards_0002 movie_0002  total_movie_sq1_0002    if movie_0306 > 0 & renter == 0 , absorb(fipscounty occ1 occ2)  vce(cluster zip)
coefplot, vertical keep(HP_change_qi1 HP_change_qi2 HP_change_qi3 HP_change_qi4) yline(0)   levels(95) name(g4, replace)

graph combine g1 g2 g3 g4, rows(2) cols(2) ysize(10) xsize(10) iscale(1)


*** Figure 9: Comparison with nationwide samples
* age
cd "$data"
use "age_comparison", replace
cd "$output"

graph bar oursample sbo_all  bls_mgt, ///
          over(age) ///
          title("") ///
          ytitle("Percentage (%)") ///
          ylabel(0(20)60) ///
          legend(cols(2) ) ///
          scheme(s2color)
* gender
cd "$data"
use "gender_comparison_v1",clear
cd "$output"

graph bar female, ///
          over(sample,  sort(female)) ///
          title("") ///
		  ytitle("Percentage (%)") ///
          legend(cols(2) ) ///
          scheme(s2color)
		  
* refinance
cd "$data"
use "refinance_comparison", clear
cd "$output"

graph bar refinance, ///
          over(category,  sort(heloc) ) ///
          title("") ///
		  ytitle("%") ///
          legend(cols(2) ) ///
          scheme(s2color)

* heloc
cd "$data"
use "heloc_comparison_v1", clear
cd "$output"

graph bar heloc, ///
          over(category,  sort(heloc) descending) ///
          title("") ///
		  ytitle("%") ///
          legend(cols(2) ) ///
          scheme(s2color)		  
		  
* home value
cd "$data"
use "home_value_v1", clear
cd "$output"

graph bar price, ///
           over(category,  sort(price) descending ) ///
          title("") ///
		  ytitle("Thousand $") ///
          legend(cols(2) ) ///
          scheme(s2color)		  
